package com.wzy.sxgc.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wzy.common.annotation.Log;
import com.wzy.common.core.controller.BaseController;
import com.wzy.common.core.domain.AjaxResult;
import com.wzy.common.enums.BusinessType;
import com.wzy.sxgc.domain.SxgcSsgt;
import com.wzy.sxgc.service.ISxgcSsgtService;
import com.wzy.common.utils.poi.ExcelUtil;
import com.wzy.common.core.page.TableDataInfo;

/**
 * 师生沟通Controller
 * 
 * @author wzy
 * @date 2025-10-19
 */
@RestController
@RequestMapping("/sxgc/ssgt")
public class SxgcSsgtController extends BaseController
{
    @Autowired
    private ISxgcSsgtService sxgcSsgtService;

    /**
     * 查询师生沟通列表
     */
    @PreAuthorize("@ss.hasPermi('sxgc:ssgt:list')")
    @GetMapping("/list")
    public TableDataInfo list(SxgcSsgt sxgcSsgt)
    {
        startPage();
        List<SxgcSsgt> list = sxgcSsgtService.selectSxgcSsgtList(sxgcSsgt);
        return getDataTable(list);
    }

    /**
     * 导出师生沟通列表
     */
    @PreAuthorize("@ss.hasPermi('sxgc:ssgt:export')")
    @Log(title = "师生沟通", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SxgcSsgt sxgcSsgt)
    {
        List<SxgcSsgt> list = sxgcSsgtService.selectSxgcSsgtList(sxgcSsgt);
        ExcelUtil<SxgcSsgt> util = new ExcelUtil<SxgcSsgt>(SxgcSsgt.class);
        util.exportExcel(response, list, "师生沟通数据");
    }

    /**
     * 获取师生沟通详细信息
     */
    @PreAuthorize("@ss.hasPermi('sxgc:ssgt:query')")
    @GetMapping(value = "/{zxId}")
    public AjaxResult getInfo(@PathVariable("zxId") Long zxId)
    {
        return success(sxgcSsgtService.selectSxgcSsgtByZxId(zxId));
    }

    /**
     * 新增师生沟通
     */
    @PreAuthorize("@ss.hasPermi('sxgc:ssgt:add')")
    @Log(title = "师生沟通", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SxgcSsgt sxgcSsgt)
    {
        return toAjax(sxgcSsgtService.insertSxgcSsgt(sxgcSsgt));
    }

    /**
     * 修改师生沟通
     */
    @PreAuthorize("@ss.hasPermi('sxgc:ssgt:edit')")
    @Log(title = "师生沟通", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SxgcSsgt sxgcSsgt)
    {
        return toAjax(sxgcSsgtService.updateSxgcSsgt(sxgcSsgt));
    }

    /**
     * 删除师生沟通
     */
    @PreAuthorize("@ss.hasPermi('sxgc:ssgt:remove')")
    @Log(title = "师生沟通", businessType = BusinessType.DELETE)
	@DeleteMapping("/{zxIds}")
    public AjaxResult remove(@PathVariable Long[] zxIds)
    {
        return toAjax(sxgcSsgtService.deleteSxgcSsgtByZxIds(zxIds));
    }
}
